package com.aoyy.controller;

import javax.servlet.http.HttpServletRequest;
import com.aoyy.model.User;
import com.aoyy.constant.Constants;
/**===================================================================================
 * Base controller <code>BaseController</code>
 * @author this author
 * @date 2017-08-07
 * ==================================================================================== */
public class BaseController {
	private int pageNo;
	
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	
	public int getPageNo() {
		return pageNo;
	}
	
	// Get sign in user from session
	protected User getSessionUser(HttpServletRequest request) {
		return (User) request.getSession().getAttribute(Constants.SESSION_USER);
	}
	
	// Set sign in user to session 
	protected void setSessionUser(HttpServletRequest request, User user) {
		request.getSession().setAttribute(Constants.SESSION_USER, user);
	}
	
	// Get board path URL from session
	protected String getSessionBoardPathURl(HttpServletRequest request) {
		return (String) request.getSession().getAttribute(Constants.BOARD_PATH_URL);
	}
	
	// Set board path URL to session
	protected void setSessionBoardPathURl(HttpServletRequest request, String boardPathURL) {
		request.getSession().setAttribute(Constants.BOARD_PATH_URL, boardPathURL);
	}
	
	// Get topic path URL from session
	protected String getSessionTopicPathURl(HttpServletRequest request) {
		return (String) request.getSession().getAttribute(Constants.TOPIC_PATH_URL);
	}
	
	// Set topic path URL to session
	protected void setSessionTopicPathURl(HttpServletRequest request, String topicPathURL) {
		request.getSession().setAttribute(Constants.TOPIC_PATH_URL, topicPathURL);
	}
	
}
